package com.chess.connections.work;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Created by wusk on 2017/12/13.
 * 线程池，服务端的所有业务都通过此线程池执行
 */
public class WorkerThreadPool {
    private ThreadPoolExecutor pool;

    public WorkerThreadPool(){
        BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
        pool = new ThreadPoolExecutor(1, 2, 2, TimeUnit.HOURS, queue);
    }

    public void process(Runnable task){
        pool.execute(task);
    }
}
